package com.zyb.warehouse.mapper;

import com.zyb.warehouse.dto.Page;
import com.zyb.warehouse.entity.OutStore;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Description:出库表持久层接口
 */
@Mapper
public interface OutStoreMapper {

    /**
     * 添加出库单
     *
     * @param outStore
     * @return
     */
    @Insert("insert into out_store values(null,#{productId},#{storeId},#{tallyId},null,#{outNum},#{createBy},now(),0)")
    Integer insertOutStore(OutStore outStore);

    /**
     * 查询出库单总记录数
     *
     * @param outStore
     * @return
     */
    Integer selectOutStoreTotal(OutStore outStore);

    /**
     * 分页查询出库单
     *
     * @param page
     * @param outStore
     * @return
     */
    List<OutStore> pageOutStore(@Param("page") Page page, @Param("outStore") OutStore outStore);

    /**
     * 修改出库单改为已入库
     *
     * @param outsId
     * @return
     */
    @Update("update out_store set is_out=1 where outs_id=#{outsId}")
    Integer updateIsOutState(Integer outsId);
}
